;solution for euler 17

(defparameter *oneswords* 
	#("" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine"))
(defparameter *teenswords*
	#("" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" 
		"seventeen" "eighteen" "nineteen"))
(defparameter *decawords*
	#("" "ten" "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety"))
	
	
(defun solve-euler17 ()
	(let ((bigstring ""))
		(loop for i from 1 to 999 do
			(when (> (floor (/ i 100)) 0)
				(setf bigstring (concatenate 'string bigstring (elt *oneswords* (floor (/ i 100)))))
				(setf bigstring (concatenate 'string bigstring "hundred"))
				(when (> (- (/ i 100) (floor (/ i 100))) 0)
					(setf bigstring (concatenate 'string bigstring "and"))))
			(cond
				((and (> (mod i 100) 10) (< (mod i 100) 20))
					(setf bigstring (concatenate 'string bigstring
							(elt *teenswords* (mod i 10)))))
				(t
					(setf bigstring (concatenate 'string bigstring 
							(elt *decawords* (floor (/ (mod i 100) 10)))))
					(setf bigstring (concatenate 'string bigstring
							(elt *oneswords* (mod i 10)))))))
		(setf bigstring (concatenate 'string bigstring "onethousand"))
		;(print bigstring)
		(format t "Euler 17:~a" (length bigstring))))